<html lang="zh-CN">
<head>
    <title>office预览</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
    <meta charset="utf-8"/>
    <!-- onlyoffice服务器地址 -->
    <script src="http://192.168.10.10:8090/web-apps/apps/api/documents/api.js"></script>
    <style>
        body {
            padding: 0;
            margin: 0;
        }
    </style>
</head>
<body>
<!-- 占位元素 -->
<div id="placeholder"></div>
<script>
    /**
     * 详细配置文档：https://api.onlyoffice.com/editors/config/
     * @param url 要预览的文档地址
     * @param filename 要预览的文档文件名
     */
    function preview(url, filename, fileType) {
        const config = {
            "document": {
                "permissions": {
                    comment: false,
                    fillForms: false,
                    "edit": false,
                },
                "fileType": fileType,
                "title": filename,
                "url": url,
                // "key": this.md5,
                "lang": "zh-CN"
            },
            "width": '100%',
            "editorConfig": {
                mode: 'view',
                "lang": "zh-CN"
            }
        };
        document.title = filename;
        const docEditor = new DocsAPI.DocEditor("placeholder", config);
    }

    let query =   location.search.substring(1);
    var values= decodeURI(query).split("&");

    console.log(values)
    // 调用方法
    preview(values[0], values[1], values[2]);
</script>
</body>
</html>

